package ru.athena.runTool.blockTypes;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;

public abstract class ExecutableBlock extends CodeBlock {

	CallableStatement stmt = null;

	public ExecutableBlock(String codeBlock) {
		super(codeBlock);
	}
	
	@Override
	public boolean isExecutable() {
		return true;
	};
	
	@Override
	public void execute(Connection conn) throws Exception {
		try {		
			stmt = conn.prepareCall( getText() );
			stmt.executeUpdate();
		} catch (SQLException e) {
			if ( stmt != null ) {	
				stmt.close();
			}
			throw e;
		}
	}

}